package com.sjht.android.bxgz.activity.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sjht.android.bxgz.R;
import com.sjht.android.bxgz.manager.ImageDownloader;

public class NewsAdapter extends BaseListAdapter<String> {

	private ImageDownloader downloader;
	private Bitmap mBitmap;

	public NewsAdapter(Context context, List<String> values) {
		super(context, values);
		// TODO Auto-generated constructor stub
		downloader = new ImageDownloader();
		// TODO Auto-generated constructor stub
		// mBitmap = BitmapFactory.decodeResource(mContext.getResources(),
		// R.drawable.driver_icon);
	}

	@Override
	protected View getItemView(View convertView, int position) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		// 如果当前位置的View为null时
		if (convertView == null) {
			// 实例化当前item的布局
			convertView = mInflater.inflate(R.layout.base_list_item, null);
			holder = new ViewHolder();
			holder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
			holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
			holder.iv_photo = (ImageView) convertView.findViewById(R.id.iv_photo);
			convertView.setTag(holder);
		} else {
			// 使用原来实例化的View
			holder = (ViewHolder) convertView.getTag();
		}
		setData(position, holder);
		return convertView;
	}

	private void setData(int position, ViewHolder holder) {
		holder.tv_content.setText(mValues.get(position));
	}

	class ViewHolder {
		TextView tv_title, tv_content;
		ImageView iv_photo;
	}
}
